package com.jsyl.lwbk.business.service.education.impl;

import com.jsyl.lwbk.business.constant.NewChildProgramConstant;
import com.jsyl.lwbk.business.domain.education.*;
import com.jsyl.lwbk.business.dto.EvaluateInfoDTO;
import com.jsyl.lwbk.business.dto.education.*;
import com.jsyl.lwbk.business.handle.AliOssHandle;
import com.jsyl.lwbk.business.mapper.education.*;
import com.jsyl.lwbk.business.service.education.IChildTrainingProgramService;
import com.jsyl.lwbk.business.service.education.ITrainingProgramChildRecordService;
import com.jsyl.lwbk.business.service.education.ITrainingProgramService;
import com.jsyl.lwbk.business.vo.education.TrainingScoreCountVO;
import com.jsyl.lwbk.common.exception.BusinessException;
import com.jsyl.lwbk.common.utils.DateUtils;
import com.jsyl.lwbk.common.utils.pdf.HtmlToPdf1Utils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.*;

/**
 * @author jh
 * @date 2020-11-02 16:18
 * @desc
 **/
@Service
public class ChildTrainingProgramServiceImpl implements IChildTrainingProgramService {

    @Autowired
    private ChildTrainingProgramMapper childTrainingProgramMapper;

    @Autowired
    private IChildTrainingProgramService childTrainingProgramService;

    @Autowired
    private ITrainingProgramChildRecordService trainingProgramChildRecordService;

    @Autowired
    private ChildPdfUrlMapper childPdfUrlMapper;

    @Autowired
    private ChildCourseMapper childCourseMapper;

    @Autowired
    private CourseChildMapper courseChildMapper;

    @Autowired
    AliOssHandle aliOssHandle;
    @Autowired
    private ChildMonthPlanMapper childMonthPlanMapper;
    @Autowired
    private ITrainingProgramService trainingProgramService;

    @Override
    public void insert(ChildTrainingProgram childTrainingProgram) {
        childTrainingProgramMapper.insert(childTrainingProgram);

    }

    @Override
    public List<ChildTrainingProgram> list(ChildTrainingProgramDTO childTrainingProgramDTO) {
        ChildTrainingProgramExample childTrainingProgramExample = new ChildTrainingProgramExample();
        ChildTrainingProgramExample.Criteria criteria = childTrainingProgramExample.createCriteria();
        criteria.andChildIdEqualTo(childTrainingProgramDTO.getChildId()).andTrainingProgramNumberEqualTo(childTrainingProgramDTO.getTrainingProgramNumber());
        if(childTrainingProgramDTO.getCenterId() != null){
            criteria.andCenterIdEqualTo(childTrainingProgramDTO.getCenterId());
        }
        if(childTrainingProgramDTO.getQuestionId() != null){
            criteria.andQuestionIdEqualTo(childTrainingProgramDTO.getQuestionId());
        }
        if(childTrainingProgramDTO.getProjectType() != null){
            criteria.andProjectTypeEqualTo(childTrainingProgramDTO.getProjectType());
        }
        if(childTrainingProgramDTO.getTrainingScore() != null){
            criteria.andTrainingScoreEqualTo(childTrainingProgramDTO.getTrainingScore());
        }
        if(childTrainingProgramDTO.getTrainingLevel() != null){
            criteria.andTrainingLevelEqualTo(childTrainingProgramDTO.getTrainingLevel());
        }
        if(childTrainingProgramDTO.getTempGenerateDay() != null){
            criteria.andTempGenerateDayIsNotNull();
        }
        if(childTrainingProgramDTO.getTrainingType() != null){
            criteria.andTrainingTypeNotEqualTo(3);
        }
        if(childTrainingProgramDTO.getEqTrainingType() != null){
            criteria.andTrainingTypeEqualTo(3);
        }

        return childTrainingProgramMapper.selectByExample(childTrainingProgramExample);
    }

    private void dealProgram(ChildTrainingProgramDTO childTrainingProgramDTO,List<String> list,Integer trainingPlan) {
        int i=1;
        for(String s: list){
            ChildTrainingProgram program =new ChildTrainingProgram();
            program.setCenterId(childTrainingProgramDTO.getCenterId());
            program.setChildId(childTrainingProgramDTO.getChildId());
            program.setTrainingProgramNumber(childTrainingProgramDTO.getTrainingProgramNumber());
            program.setProjectType(childTrainingProgramDTO.getProjectType());
            program.setTrainingType(3);
            program.setTrainingPlan(trainingPlan*10);
            program.setTrainingModule(trainingPlan*10);
            if(childTrainingProgramDTO.getProjectType().equals(1) && trainingPlan.equals(4) && i<=7){
                program.setTrainingPlan(41);
            }
            if(childTrainingProgramDTO.getProjectType().equals(1) && trainingPlan.equals(4) && i>7){
                program.setTrainingPlan(42);
            }
            i++;
            program.setTrainingContent(s);
            program.setStatus(0);
            this.childTrainingProgramMapper.insert(program);
        }
    }

    @Override
    public List<ChildTrainingProgram> findByChildAndProjecttype(ChildTrainingProgramDTO childTrainingProgramDTO) {
        ChildTrainingProgramExample childTrainingProgramExample = new ChildTrainingProgramExample();
        ChildTrainingProgramExample.Criteria criteria = childTrainingProgramExample.createCriteria();
        criteria.andChildIdEqualTo(childTrainingProgramDTO.getChildId()).andProjectTypeEqualTo(childTrainingProgramDTO.getProjectType());
//        if(childTrainingProgramDTO.getCenterId() != null){
//            criteria.andCenterIdEqualTo(childTrainingProgramDTO.getCenterId());
//        }
        if(childTrainingProgramDTO.getIsChoosed() != null){
            criteria.andIsChoosedEqualTo(childTrainingProgramDTO.getIsChoosed());
        }
        if(!StringUtils.isEmpty(childTrainingProgramDTO.getTrainingProgramNumber())){
            criteria.andTrainingProgramNumberEqualTo(childTrainingProgramDTO.getTrainingProgramNumber());
        }
        if(childTrainingProgramDTO.getTrainingType() != null){
            criteria.andTrainingTypeEqualTo(childTrainingProgramDTO.getTrainingType());
        }
        childTrainingProgramExample.setOrderByClause("training_type asc,(training_num+0) asc,training_plan asc");
        List<ChildTrainingProgram> childTrainingPrograms =  childTrainingProgramMapper.selectByExample(childTrainingProgramExample);
        if(childTrainingProgramDTO.getIsNewProgram()!=null && childTrainingProgramDTO.getIsNewProgram().equals(1) && CollectionUtils.isEmpty(childTrainingPrograms)){
            //新生时插入标准计划
            if(childTrainingProgramDTO.getProjectType() == 1){
                dealProgram(childTrainingProgramDTO,NewChildProgramConstant.sportOne,3);
                dealProgram(childTrainingProgramDTO,NewChildProgramConstant.sportTwo,4);
                dealProgram(childTrainingProgramDTO,NewChildProgramConstant.sportThree,5);
            }
            if(childTrainingProgramDTO.getProjectType() == 2){
                dealProgram(childTrainingProgramDTO,NewChildProgramConstant.knowledgeOne,3);
                dealProgram(childTrainingProgramDTO,NewChildProgramConstant.knowledgeTwo,4);
                dealProgram(childTrainingProgramDTO,NewChildProgramConstant.knowledgeThree,5);
            }
            if(childTrainingProgramDTO.getProjectType() == 3){
                dealProgram(childTrainingProgramDTO,NewChildProgramConstant.languageOne,3);
                dealProgram(childTrainingProgramDTO,NewChildProgramConstant.languageTwo,4);
                dealProgram(childTrainingProgramDTO,NewChildProgramConstant.languageThree,5);
            }
            childTrainingPrograms =  childTrainingProgramMapper.selectByExample(childTrainingProgramExample);
        }
        if(!CollectionUtils.isEmpty(childTrainingPrograms)){
            for(ChildTrainingProgram childTrainingProgram:childTrainingPrograms){
                //显示修改后的训练目标
                setTrainingContent(childTrainingProgram);
                if(childTrainingProgramDTO.getRequestType()!=null){
                    if(childTrainingProgramDTO.getRequestType() == 1||childTrainingProgramDTO.getRequestType() == 3){
                        if(childTrainingProgram.getTrainingType()==2) {
                            childTrainingProgram.setTrainingContent("*" + childTrainingProgram.getTrainingContent());
                        }
                    }
                }
            }
            //查询对应的录入成绩
            if(childTrainingProgramDTO.getRequestType()!=null && childTrainingProgramDTO.getRequestType() == 1){
                TrainingProgramChildRecordListDTO trainingProgramChildRecordListDTO = new TrainingProgramChildRecordListDTO();
//                trainingProgramChildRecordListDTO.setCenterId(childTrainingProgramDTO.getCenterId());
                trainingProgramChildRecordListDTO.setChildId(childTrainingProgramDTO.getChildId());
                trainingProgramChildRecordListDTO.setProjectType(childTrainingProgramDTO.getProjectType());
                trainingProgramChildRecordListDTO.setTrainingTime(childTrainingProgramDTO.getTrainingTime());
                trainingProgramChildRecordListDTO.setCourseId(childTrainingProgramDTO.getCourseId());
                List<TrainingProgramChildRecord> trainingProgramChildRecords = trainingProgramChildRecordService.list(trainingProgramChildRecordListDTO);
                if(!CollectionUtils.isEmpty(trainingProgramChildRecords)){
                    for(ChildTrainingProgram childTrainingProgram:childTrainingPrograms){
                        for(TrainingProgramChildRecord trainingProgramChildRecord:trainingProgramChildRecords){
                            if(childTrainingProgram.getId().equals(trainingProgramChildRecord.getChildTrainingProgramId())){
                                childTrainingProgram.setCompleteNum(trainingProgramChildRecord.getCompleteNum());
                                childTrainingProgram.setTotalNum(trainingProgramChildRecord.getTotalNum());
                                childTrainingProgram.setNoTraining(trainingProgramChildRecord.getNoTraining());
                            }
                        }
                    }
                }
            }

        }

        return childTrainingPrograms;
    }

    @Override
    public List<ChildTrainingProgram> findByChildAndEvaluate(ChildTrainingProgramDTO childTrainingProgramDTO) {
        ChildTrainingProgramExample childTrainingProgramExample = new ChildTrainingProgramExample();
        ChildTrainingProgramExample.Criteria criteria = childTrainingProgramExample.createCriteria();
        criteria.andChildIdEqualTo(childTrainingProgramDTO.getChildId());
        if(childTrainingProgramDTO.getEvaluateNumber() != null){
            criteria.andEvaluateNumberEqualTo(childTrainingProgramDTO.getEvaluateNumber());
        }
        childTrainingProgramExample.setOrderByClause("training_type asc,(training_num+0) asc,training_plan asc");
        List<ChildTrainingProgram> childTrainingPrograms =  childTrainingProgramMapper.selectByExample(childTrainingProgramExample);

        return childTrainingPrograms;
    }

    @Override
    public ChildTrainingProgram findById(Long id) {
        ChildTrainingProgramExample childTrainingProgramExample = new ChildTrainingProgramExample();
        ChildTrainingProgramExample.Criteria criteria = childTrainingProgramExample.createCriteria();
        criteria.andIdEqualTo(id);
        List<ChildTrainingProgram>  childTrainingPrograms = childTrainingProgramMapper.selectByExample(childTrainingProgramExample);
        if(!CollectionUtils.isEmpty(childTrainingPrograms)){
            ChildTrainingProgram childTrainingProgram = childTrainingPrograms.get(0);
            return setTrainingContent(childTrainingProgram);
        }
        return null;
    }

    private ChildTrainingProgram setTrainingContent(ChildTrainingProgram childTrainingProgram){
        if(!StringUtils.isEmpty(childTrainingProgram.getModifyTrainingContent()) && !StringUtils.isEmpty(childTrainingProgram.getTrainingContent())){
            String beforeModify = childTrainingProgram.getModifyContent();
            String correct = beforeModify.split("\\[")[1].split("\\]")[0];
            beforeModify = beforeModify.replace("[","").replace("]","");

            String afterModify = childTrainingProgram.getModifyTrainingContent();
            afterModify = afterModify.replace("[","").replace("]","(标准值"+correct+")");
            childTrainingProgram.setCorrectNumTip("("+correct+")");
//            if(childTrainingProgram.getModifyContent().indexOf("min")>-1){
//                childTrainingProgram.setCorrectNumTip("("+(Integer.valueOf(correct)*60)+")");
//            }
            childTrainingProgram.setTrainingContent(childTrainingProgram.getTrainingContent().replace(beforeModify,afterModify));
        }
        return childTrainingProgram;
    }

    @Override
    public List<ChildTrainingProgram> selectQuestion(ChildTrainingProgramDTO childTrainingProgramDTO) {
        return childTrainingProgramMapper.selectQuestion(childTrainingProgramDTO);
    }

    @Override
    public List<TrainingScoreCountVO> selectTrainingScoreCount(ChildTrainingProgramDTO childTrainingProgramDTO) {
        return childTrainingProgramMapper.selectTrainingScoreCount(childTrainingProgramDTO);
    }

    @Override
    @Transactional
    public void updateChildTrainingProgram(EditTrainingProgramDTO editTrainingProgramDTO) {
        ChildTrainingProgram childTrainingProgram = findById(editTrainingProgramDTO.getId());
        if(childTrainingProgram == null){
            return;
        }
        String modifyConent = childTrainingProgram.getModifyContent();
        if(StringUtils.isEmpty(modifyConent)){
            return;
        }
        String pre = modifyConent.substring(0,modifyConent.indexOf("["));
        String after = modifyConent.substring(modifyConent.indexOf("]")+1);
        String afterMoidfy = pre+"["+editTrainingProgramDTO.getAfterModify()+"]"+after;
        ChildTrainingProgram edChildTrainingProgram = new ChildTrainingProgram();
        edChildTrainingProgram.setId(editTrainingProgramDTO.getId());
        edChildTrainingProgram.setModifyTrainingContent(afterMoidfy);
        ChildTrainingProgramExample example = new ChildTrainingProgramExample();
        example.createCriteria().andIdEqualTo(editTrainingProgramDTO.getId());
        childTrainingProgramMapper.updateByExampleSelective(edChildTrainingProgram,example);
    }

    @Override
    public void replaceChildTrainingProgram(EditTrainingProgramDTO dto) {
        ChildTrainingProgram childTrainingProgram = findById(dto.getOldChildTrainingId());
        if(childTrainingProgram == null){
            return;
        }
        TrainingProgram trainingProgram =trainingProgramService.findbyId(dto.getNewProgramId());
        if(trainingProgram == null){
            return;
        }
        //新增选择的替换项目
        ChildTrainingProgram newChildTrainingProgram =new ChildTrainingProgram();
        BeanUtils.copyProperties(childTrainingProgram,newChildTrainingProgram);
        newChildTrainingProgram.setId(null);
        newChildTrainingProgram.setAfterReplaceId(childTrainingProgram.getId());
        newChildTrainingProgram.setTrainingContent(trainingProgram.getTrainingContent());
        newChildTrainingProgram.setInputType(trainingProgram.getInputType());
        newChildTrainingProgram.setModifyDirection(trainingProgram.getModifyDirection());
        newChildTrainingProgram.setTrainingName(trainingProgram.getTrainingName());
        newChildTrainingProgram.setModifyContent(trainingProgram.getModifyContent());
        newChildTrainingProgram.setTrainingProgramId(trainingProgram.getId());
        newChildTrainingProgram.setCreateTime(DateUtils.getNowDate());
        newChildTrainingProgram.setUpdateTime(DateUtils.getNowDate());
        newChildTrainingProgram.setStatus(0);
        childTrainingProgramMapper.insert(newChildTrainingProgram);
        //删除原项目
        childTrainingProgramMapper.updateStstus(childTrainingProgram.getId(),2);
    }

    @Override
    public void revokeChildTrainingProgram(EditTrainingProgramDTO dto) {
        ChildTrainingProgram childTrainingProgram = findById(dto.getId());
        if(childTrainingProgram == null){
            return;
        }
        //还原替换
        childTrainingProgramMapper.updateStstus(childTrainingProgram.getAfterReplaceId(),0);
        ChildTrainingProgramExample example =new ChildTrainingProgramExample();
        example.createCriteria().andIdEqualTo(childTrainingProgram.getId());
        childTrainingProgramMapper.deleteByExample(example);
    }

    @Override
    public List<ChildTrainingProgram> listLastConsolidates(TrainingProgramChildRecordListDTO trainingProgramChildRecordListDTO) {
        ChildTrainingProgramExample selectExample = new ChildTrainingProgramExample();
        ChildTrainingProgramExample.Criteria criteria = selectExample.createCriteria();
        criteria.andChildIdEqualTo(trainingProgramChildRecordListDTO.getChildId()).andProjectTypeEqualTo(trainingProgramChildRecordListDTO.getProjectType())
                .andTrainingProgramNumberEqualTo(DateUtils.getLastMonth(trainingProgramChildRecordListDTO.getTrainingProgramNumber())).andTrainingLevelEqualTo(2);
        return childTrainingProgramMapper.selectByExample(selectExample);
    }

    @Override
    public List<ChildTrainingProgram> listReplaceTrainingProgram(Long programId,String trainingContent) {
        return childTrainingProgramMapper.listReplaceTrainingProgram(programId,trainingContent);
    }

    @Override
    public List<ChildTrainingProgram> listConsolidates(ListConsolidatesDTO listConsolidatesDTO) {
        ChildTrainingProgramExample selectExample = new ChildTrainingProgramExample();
        ChildTrainingProgramExample.Criteria criteria = selectExample.createCriteria();
        criteria.andChildIdEqualTo(listConsolidatesDTO.getChildId()).andProjectTypeEqualTo(listConsolidatesDTO.getProjectType())
                .andTrainingProgramNumberEqualTo(listConsolidatesDTO.getScheduleTime()).andTrainingTypeEqualTo(2);
        return childTrainingProgramMapper.selectByExample(selectExample);
    }

    @Override
    public CheckProgramDTO getCheckProgramDTO(ListConsolidatesDTO listConsolidatesDTO) {
        CheckProgramDTO checkProgramDTO = new CheckProgramDTO();
        ChildTrainingProgramExample selectExample = new ChildTrainingProgramExample();
        ChildTrainingProgramExample.Criteria criteria = selectExample.createCriteria();
        criteria.andChildIdEqualTo(listConsolidatesDTO.getChildId()).andProjectTypeEqualTo(listConsolidatesDTO.getProjectType())
                .andTrainingProgramNumberEqualTo(listConsolidatesDTO.getScheduleTime()).andIsChoosedEqualTo(1);
        selectExample.setOrderByClause("training_type asc,(training_num+0) asc,training_plan asc");
        List<ChildTrainingProgram> childTrainingPrograms =  childTrainingProgramMapper.selectByExample(selectExample);
        if(!CollectionUtils.isEmpty(childTrainingPrograms)) {
            for (ChildTrainingProgram childTrainingProgram : childTrainingPrograms) {
                //显示修改后的训练目标
                setTrainingContent(childTrainingProgram);
            }
        }
        checkProgramDTO.setChildTrainingPrograms(childTrainingPrograms);
        return checkProgramDTO;
    }

    @Override
    @Transactional
    public void saveChildTrainingProgram(SaveChildTrainingProgramDTO saveChildTrainingProgramDTO, String loginName) {
        List<Long> programeIds = saveChildTrainingProgramDTO.getProgrameIds();
        List<Long> curIndexs = saveChildTrainingProgramDTO.getCurIndexs();
        if(programeIds.size() != curIndexs.size()){
            throw new BusinessException("题目序号不正确");
        }
        for(int i=0;i<programeIds.size();i++){
            //i本来是11，现在是10，说明10选了2题
            if(curIndexs.get(i)-1 < i){
                throw new BusinessException("第"+i+"题A、B类型必须且只能选1题");
            }
            //i本来是11，现在是12，说明12选了2题
            else if(curIndexs.get(i)-1 > i){
                throw new BusinessException("第"+(i+1)+"题A、B类型必须且只能选1题");
            }
         /* ChildTrainingProgram childTrainingProgram = childTrainingProgramService.findById(programeIds.get(i));
          if(childTrainingProgram == null){
              throw new BusinessException("id不正确");
          }
          if(StringUtils.isEmpty(childTrainingProgram.getTrainingNum())){
              throw new BusinessException("题目编号为空");
          }
          ChildTrainingProgram pre = childTrainingProgramService.findById(programeIds.get(i-1));
          Integer  num = Integer.parseInt(childTrainingProgram.getTrainingNum());
          Integer  preNum = Integer.parseInt(pre.getTrainingNum());
          if(num - preNum!=1){
              throw new BusinessException("第"+curIndexs.get(i-1)+"题A、B类型必须且只能选1题");
          }*/

        }
        ChildTrainingProgramExample selectExample = new ChildTrainingProgramExample();
        ChildTrainingProgramExample.Criteria criteria = selectExample.createCriteria();
        criteria.andChildIdEqualTo(saveChildTrainingProgramDTO.getChildId()).andProjectTypeEqualTo(saveChildTrainingProgramDTO.getProjectType())
                     .andTrainingProgramNumberEqualTo(saveChildTrainingProgramDTO.getScheduleTime());
        childTrainingProgramMapper.updateAllUnSelected(selectExample);
        List<Long> programsIds = saveChildTrainingProgramDTO.getProgrameIds();
        for(Long id:programsIds){
            ChildTrainingProgram childTrainingProgram = new ChildTrainingProgram();
            childTrainingProgram.setId(id);
            childTrainingProgram.setIsChoosed(1);
            ChildTrainingProgramExample childTrainingProgramExample = new ChildTrainingProgramExample();
            childTrainingProgramExample.createCriteria().andIdEqualTo(id);
            childTrainingProgramMapper.updateByExampleSelective(childTrainingProgram,childTrainingProgramExample);
        }
        if(!CollectionUtils.isEmpty(saveChildTrainingProgramDTO.getConsolidates())){
            List<ConsolidateDTO> consolidateDTOS = saveChildTrainingProgramDTO.getConsolidates();

            //查询需要保存列表的值
            List<ChildTrainingProgram> childTrainingPrograms = new ArrayList<ChildTrainingProgram>();
            for(ConsolidateDTO consolidateDTO :consolidateDTOS) {
                ChildTrainingProgram childTrainingProgram = findById(consolidateDTO.getId());
                if (childTrainingProgram != null) {
                    childTrainingProgram.setId(null);
                    childTrainingProgram.setIsChoosed(1);
                    childTrainingProgram.setTrainingProgramNumber(saveChildTrainingProgramDTO.getScheduleTime());
                    childTrainingProgram.setTrainingType(2);
                    childTrainingProgram.setCreateBy(loginName);
                    childTrainingProgram.setUpdateBy(loginName);
                    childTrainingProgram.setCreateTime(new Date());
                    childTrainingProgram.setUpdateTime(new Date());
                    childTrainingPrograms.add(childTrainingProgram);
                }
            }

            //删除旧的值
            criteria.andTrainingTypeEqualTo(2);
            childTrainingProgramMapper.deleteByExample(selectExample);

            //插入新的值
           if(!CollectionUtils.isEmpty(childTrainingPrograms)){
               for(ChildTrainingProgram childTrainingProgram: childTrainingPrograms){
                   childTrainingProgramMapper.insert(childTrainingProgram);
               }
           }
        }
        if(CollectionUtils.isEmpty(saveChildTrainingProgramDTO.getConsolidates())){
            //删除旧的值
            criteria.andTrainingTypeEqualTo(2);
            childTrainingProgramMapper.deleteByExample(selectExample);

        }
        //删除新生标准计划
        this.childTrainingProgramMapper.deleteNewProgram(saveChildTrainingProgramDTO.getChildId(),saveChildTrainingProgramDTO.getScheduleTime(),saveChildTrainingProgramDTO.getProjectType());
        //更新状态为已确认
//        ChildCourseExample childCourseExample = new ChildCourseExample();
//        childCourseExample.createCriteria().andProjectTypeEqualTo(saveChildTrainingProgramDTO.getProjectType())
//                .andDayDateBetween(DateUtils.getMonthBegin(DateUtils.getStrTime(saveChildTrainingProgramDTO.getScheduleTime())),DateUtils.getMonthEnd(DateUtils.getStrTime(saveChildTrainingProgramDTO.getScheduleTime())));
//        List<ChildCourse> childCourses = childCourseMapper.selectByExample(childCourseExample);
//        if(!CollectionUtils.isEmpty(childCourses)){
//            for(ChildCourse childCourse:childCourses){
//                //最后更新人
//                CourseChildExample courseChildExample = new CourseChildExample();
//                courseChildExample.createCriteria().andChildIdEqualTo(saveChildTrainingProgramDTO.getChildId()).andCourseIdEqualTo(childCourse.getId()).andStatusEqualTo(0);
//                List<CourseChild> courseChildList = courseChildMapper.selectByExample(courseChildExample);
//                if(!CollectionUtils.isEmpty(courseChildList) && courseChildList.size()==1){
//                    CourseChild courseChild = courseChildList.get(0);
//                    courseChild.setConfirm(1);
//                    courseChild.setLastConfirmTime(new Date());
//                    courseChild.setUpdateBy(loginName);
//                    courseChildMapper.updateByExample(courseChild,courseChildExample);
//                }
//
//            }
//        }
        childTrainingProgramMapper.updateConfirmDate(saveChildTrainingProgramDTO.getChildId(),saveChildTrainingProgramDTO.getProjectType(),saveChildTrainingProgramDTO.getScheduleTime(),DateUtils.getDate(),loginName);
        //增加月度计划记录
        ChildReport childReport =new ChildReport();
        childReport.setChildId(saveChildTrainingProgramDTO.getChildId());
        childReport.setTrainingProgramNumber(saveChildTrainingProgramDTO.getScheduleTime());
        childReport.setProjectType(saveChildTrainingProgramDTO.getProjectType());
        childReport.setCenterId(saveChildTrainingProgramDTO.getSelectCenterId());
        ChildReport local = this.childMonthPlanMapper.getChildMonthPlan(childReport);
        if(local ==null){
            childReport.setReportType(1);
            childReport.setStatus(0);
            childReport.setCreateBy(loginName);
            childReport.setCreateTime(DateUtils.getNowDate());
            childReport.setUpdateBy(loginName);
            childReport.setUpdateTime(DateUtils.getNowDate());
            this.childMonthPlanMapper.insert(childReport);
        }else {
            local.setCenterId(saveChildTrainingProgramDTO.getSelectCenterId());
            local.setUpdateBy(loginName);
            local.setUpdateTime(DateUtils.getNowDate());
            this.childMonthPlanMapper.updateById(local);
        }
    }

    @Override
    public void saveNewChildTrainingProgram(SaveChildTrainingProgramDTO saveChildTrainingProgramDTO, String loginName) {
        List<Long> programeIds = saveChildTrainingProgramDTO.getProgrameIds();
        List<Long> curIndexs = saveChildTrainingProgramDTO.getCurIndexs();
        if(programeIds.size() != curIndexs.size()){
            throw new BusinessException("题目序号不正确");
        }
        ChildTrainingProgramExample selectExample = new ChildTrainingProgramExample();
        ChildTrainingProgramExample.Criteria criteria = selectExample.createCriteria();
        criteria.andChildIdEqualTo(saveChildTrainingProgramDTO.getChildId()).andProjectTypeEqualTo(saveChildTrainingProgramDTO.getProjectType())
                .andTrainingProgramNumberEqualTo(saveChildTrainingProgramDTO.getScheduleTime());
        childTrainingProgramMapper.updateAllUnSelected(selectExample);
        List<Long> programsIds = saveChildTrainingProgramDTO.getProgrameIds();
        for(Long id:programsIds){
            ChildTrainingProgram childTrainingProgram = new ChildTrainingProgram();
            childTrainingProgram.setId(id);
            childTrainingProgram.setIsChoosed(1);
            ChildTrainingProgramExample childTrainingProgramExample = new ChildTrainingProgramExample();
            childTrainingProgramExample.createCriteria().andIdEqualTo(id);
            childTrainingProgramMapper.updateByExampleSelective(childTrainingProgram,childTrainingProgramExample);
        }

        //更新状态为已确认
//        ChildCourseExample childCourseExample = new ChildCourseExample();
//        childCourseExample.createCriteria().andProjectTypeEqualTo(saveChildTrainingProgramDTO.getProjectType())
//                .andDayDateBetween(DateUtils.getMonthBegin(DateUtils.getStrTime(saveChildTrainingProgramDTO.getScheduleTime())),DateUtils.getMonthEnd(DateUtils.getStrTime(saveChildTrainingProgramDTO.getScheduleTime())));
//        List<ChildCourse> childCourses = childCourseMapper.selectByExample(childCourseExample);
//        if(!CollectionUtils.isEmpty(childCourses)){
//            for(ChildCourse childCourse:childCourses){
//                //最后更新人
//                CourseChildExample courseChildExample = new CourseChildExample();
//                courseChildExample.createCriteria().andChildIdEqualTo(saveChildTrainingProgramDTO.getChildId()).andCourseIdEqualTo(childCourse.getId()).andStatusEqualTo(0);
//                List<CourseChild> courseChildList = courseChildMapper.selectByExample(courseChildExample);
//                if(!CollectionUtils.isEmpty(courseChildList) && courseChildList.size()==1){
//                    CourseChild courseChild = courseChildList.get(0);
//                    courseChild.setConfirm(1);
//                    courseChild.setLastConfirmTime(new Date());
//                    courseChild.setUpdateBy(loginName);
//                    courseChildMapper.updateByExample(courseChild,courseChildExample);
//                }
//
//            }
//        }
        childTrainingProgramMapper.updateConfirmDate(saveChildTrainingProgramDTO.getChildId(),saveChildTrainingProgramDTO.getProjectType(),saveChildTrainingProgramDTO.getScheduleTime(),DateUtils.getDate(),loginName);
        //增加月度计划记录
        ChildReport childReport =new ChildReport();
        childReport.setChildId(saveChildTrainingProgramDTO.getChildId());
        childReport.setTrainingProgramNumber(saveChildTrainingProgramDTO.getScheduleTime());
        childReport.setProjectType(saveChildTrainingProgramDTO.getProjectType());
        childReport.setCenterId(saveChildTrainingProgramDTO.getSelectCenterId());
        ChildReport local = this.childMonthPlanMapper.getChildMonthPlan(childReport);
        if(local ==null){
            childReport.setReportType(1);
            childReport.setStatus(0);
            childReport.setCreateBy(loginName);
            childReport.setCreateTime(DateUtils.getNowDate());
            childReport.setUpdateBy(loginName);
            childReport.setUpdateTime(DateUtils.getNowDate());
            this.childMonthPlanMapper.insert(childReport);
        }else {
            local.setCenterId(saveChildTrainingProgramDTO.getSelectCenterId());
            local.setUpdateBy(loginName);
            local.setUpdateTime(DateUtils.getNowDate());
            this.childMonthPlanMapper.updateById(local);
        }
    }

    @Override
    @Transactional
    public String downloadTrainingProgramTeacher(ListConsolidatesDTO listConsolidatesDTO,CheckProgramDTO checkProgramDTO,Integer urlType,String loginName) {
        ChildPdfUrlExample childPdfUrlExample = new ChildPdfUrlExample();
        childPdfUrlExample.createCriteria().andCenterIdEqualTo(listConsolidatesDTO.getCenterId()).andChildIdEqualTo(listConsolidatesDTO.getChildId()).andTrainingProgramNumberEqualTo(listConsolidatesDTO.getScheduleTime())
                .andUrlTypeEqualTo(urlType)
                .andProjectTypeEqualTo(listConsolidatesDTO.getProjectType());
        List<ChildPdfUrl> childPdfUrls = childPdfUrlMapper.selectByExample(childPdfUrlExample);
        if(!CollectionUtils.isEmpty(childPdfUrls)){
            childPdfUrlMapper.deleteByExample(childPdfUrlExample);
//            return childPdfUrls.get(0).getPdfUrl();
        }
        //未生成记录时，去生成报告
        String dest = createRender(listConsolidatesDTO,checkProgramDTO,urlType);
        File file = new File(dest);
        //保存报告到oss
        String fileUrl = null;
        try {
            String fileName = file.getName();
            fileUrl = aliOssHandle.upload(fileName, null, new FileInputStream(file));
        } catch (FileNotFoundException e) {
           throw new BusinessException(e.getMessage());
        }
        ChildPdfUrl childPdfUrl = new ChildPdfUrl();
        childPdfUrl.setCenterId(listConsolidatesDTO.getCenterId());
        childPdfUrl.setChildId(listConsolidatesDTO.getChildId());
        childPdfUrl.setProjectType(listConsolidatesDTO.getProjectType());
        childPdfUrl.setTrainingProgramNumber(listConsolidatesDTO.getScheduleTime());
        childPdfUrl.setUrlType(urlType);
        childPdfUrl.setPdfUrl(fileUrl);
        childPdfUrl.setUpdateBy(loginName);
        childPdfUrl.setUpdateTime(new Date());
        childPdfUrlMapper.insert(childPdfUrl);
        return fileUrl;
    }


    @Override
    public String downloadTrainingReport(TrainingProgramChildRecordListDTO trainingProgramChildRecordListDTO, TrainingReportDTO trainingReportDTO, Integer urlType, String loginName) {
        ChildPdfUrlExample childPdfUrlExample = new ChildPdfUrlExample();
        childPdfUrlExample.createCriteria().andChildIdEqualTo(trainingReportDTO.getChildId()).andTrainingProgramNumberEqualTo(trainingProgramChildRecordListDTO.getTrainingProgramNumber())
                .andUrlTypeEqualTo(urlType);
        List<ChildPdfUrl> childPdfUrls = childPdfUrlMapper.selectByExample(childPdfUrlExample);
        //已存在就删掉重新生成
        if(!CollectionUtils.isEmpty(childPdfUrls)){
            childPdfUrlMapper.deleteByExample(childPdfUrlExample);
//            return childPdfUrls.get(0).getPdfUrl();
        }
        //未生成记录时，去生成报告
        String dest = createReportRender(trainingReportDTO);
        File file = new File(dest);
        //保存报告到oss
        String fileUrl = null;
        try {
            String fileName = file.getName();
            fileUrl = aliOssHandle.upload(fileName, null, new FileInputStream(file));
        } catch (FileNotFoundException e) {
            throw new BusinessException(e.getMessage());
        }
        ChildPdfUrl childPdfUrl = new ChildPdfUrl();
        childPdfUrl.setCenterId(trainingProgramChildRecordListDTO.getCenterId());
        childPdfUrl.setChildId(trainingReportDTO.getChildId());
        childPdfUrl.setTrainingProgramNumber(trainingReportDTO.getScheduleTime());
        childPdfUrl.setUrlType(urlType);
        childPdfUrl.setPdfUrl(fileUrl);
        childPdfUrl.setUpdateBy(loginName);
        childPdfUrl.setUpdateTime(new Date());
        childPdfUrlMapper.insert(childPdfUrl);
        return fileUrl;
    }

    public String createRender(ListConsolidatesDTO listConsolidatesDTO,CheckProgramDTO checkProgramDTO, Integer urlType) {
        // 创建渲染PDF内容
        Map<String, Object> map = new HashMap<>();
        // 基础信息
        map.put("childName", checkProgramDTO.getChildName());
        map.put("childAge", checkProgramDTO.getChildage());
        map.put("teacherName", checkProgramDTO.getTeacherName());
        map.put("monthTime", checkProgramDTO.getMonthTime()+ checkProgramDTO.getProjectName() +"月度计划");
        map.put("projectName", checkProgramDTO.getProjectName());
        map.put("scheduleTime", checkProgramDTO.getScheduleTime());

        List<ChildTrainingProgram> childTrainingPrograms = checkProgramDTO.getChildTrainingPrograms();
        if(urlType == 1) {
            List<Map> program1 = new ArrayList<>();
            List<Map> program2 = new ArrayList<>();
            List<Map> program3 = new ArrayList<>();
            List<Map> program4 = new ArrayList<>();
            List<Map> program5 = new ArrayList<>();
            List<Map> program6 = new ArrayList<>();
            List<Map> program7 =new ArrayList<>();
            List<Map> program8 =new ArrayList<>();
            List<Map> program9 = new ArrayList<>();

            List<Map> program30 = new ArrayList<>();
            List<Map> program40 = new ArrayList<>();
            List<Map> program41 = new ArrayList<>();
            List<Map> program42 = new ArrayList<>();
            List<Map> program50 = new ArrayList<>();
            for (int i = 0; i < childTrainingPrograms.size(); i++) {
                if(childTrainingPrograms.get(i).getTrainingModule()!=null) {
                    Map temp =new HashMap();
                    if (childTrainingPrograms.get(i).getTrainingModule() == 1){
                        temp.put("name",childTrainingPrograms.get(i).getTrainingName());
//                        if(childTrainingPrograms.get(i).getTrainingContent() !=null &&
//                                childTrainingPrograms.get(i).getTrainingContent().length()>30){
//                            childTrainingPrograms.get(i).setTrainingContent(childTrainingPrograms.get(i).getTrainingContent().substring(0,30)+"...");
//                        }
                        if (childTrainingPrograms.get(i).getTrainingType() != null && childTrainingPrograms.get(i).getTrainingType() == 2) {
                            temp.put("content","*"+childTrainingPrograms.get(i).getTrainingContent());
                            program1.add(temp);
                        }
                        else {
                            temp.put("content",childTrainingPrograms.get(i).getTrainingContent());
                            program1.add(temp);
                        }
                    }
                    else  if (childTrainingPrograms.get(i).getTrainingModule() == 2){
                        temp.put("name",childTrainingPrograms.get(i).getTrainingName());
                        if (childTrainingPrograms.get(i).getTrainingType() != null && childTrainingPrograms.get(i).getTrainingType() == 2) {
                            temp.put("content","*"+childTrainingPrograms.get(i).getTrainingContent() );
                            program2.add(temp);
                        }
                        else {
                            temp.put("content",childTrainingPrograms.get(i).getTrainingContent());
                            program2.add(temp);
                        }
                    }
                    else  if (childTrainingPrograms.get(i).getTrainingModule() == 3){
                        temp.put("name",childTrainingPrograms.get(i).getTrainingName());
                        if (childTrainingPrograms.get(i).getTrainingType() != null && childTrainingPrograms.get(i).getTrainingType() == 2) {
                            temp.put("content","*"+childTrainingPrograms.get(i).getTrainingContent());
                            program3.add(temp);
                        }
                        else {
                            temp.put("content",childTrainingPrograms.get(i).getTrainingContent() );
                            program3.add(temp);
                        }
                    }
                    else  if (childTrainingPrograms.get(i).getTrainingModule() == 4){
                        temp.put("name",childTrainingPrograms.get(i).getTrainingName());
                        if (childTrainingPrograms.get(i).getTrainingType() != null && childTrainingPrograms.get(i).getTrainingType() == 2) {
                            temp.put("content","*"+ childTrainingPrograms.get(i).getTrainingContent());
                            program4.add(temp);
                        }
                        else{
                            temp.put("content",childTrainingPrograms.get(i).getTrainingContent());
                            program4.add(temp);
                        }
                    }
                    else  if (childTrainingPrograms.get(i).getTrainingModule() == 5){
                        temp.put("name",childTrainingPrograms.get(i).getTrainingName());
                        if (childTrainingPrograms.get(i).getTrainingType() != null && childTrainingPrograms.get(i).getTrainingType() == 2) {
                            temp.put("content","*"+childTrainingPrograms.get(i).getTrainingContent());
                            program5.add(temp);
                        }
                        else {
                            temp.put("content",childTrainingPrograms.get(i).getTrainingContent());
                            program5.add(temp);
                        }
                    }
                    else  if (childTrainingPrograms.get(i).getTrainingModule() == 6){
                        temp.put("name",childTrainingPrograms.get(i).getTrainingName());
                        if (childTrainingPrograms.get(i).getTrainingType() != null && childTrainingPrograms.get(i).getTrainingType() == 2) {
                            temp.put("content","*"+ childTrainingPrograms.get(i).getTrainingContent() );
                            program6.add(temp);
                        }
                        else {
                            temp.put("content",childTrainingPrograms.get(i).getTrainingContent() );
                            program6.add(temp);
                        }
                    }
                    else  if (childTrainingPrograms.get(i).getTrainingModule() == 7){
                        temp.put("name",childTrainingPrograms.get(i).getTrainingName());
                        if (childTrainingPrograms.get(i).getTrainingType() != null && childTrainingPrograms.get(i).getTrainingType() == 2) {
                            temp.put("content","*"+  childTrainingPrograms.get(i).getTrainingContent());
                            program7.add(temp);
                        }
                        else {
                            temp.put("content",childTrainingPrograms.get(i).getTrainingContent());
                            program7.add(temp);
                        }
                    }
                    else  if (childTrainingPrograms.get(i).getTrainingModule() == 8){
                        temp.put("name",childTrainingPrograms.get(i).getTrainingName());
                        if (childTrainingPrograms.get(i).getTrainingType() != null && childTrainingPrograms.get(i).getTrainingType() == 2) {
                            temp.put("content","*"+ childTrainingPrograms.get(i).getTrainingContent());
                            program8.add(temp);
                        }
                        else{
                            temp.put("content",childTrainingPrograms.get(i).getTrainingContent());
                            program8.add(temp);
                        }
                    }
                    else  if (childTrainingPrograms.get(i).getTrainingModule() == 9){
                        temp.put("name",childTrainingPrograms.get(i).getTrainingName());
                        if (childTrainingPrograms.get(i).getTrainingType() != null && childTrainingPrograms.get(i).getTrainingType() == 2) {
                            temp.put("content","*"+ childTrainingPrograms.get(i).getTrainingContent());
                            program9.add(temp);
                        }
                        else {
                            temp.put("content", childTrainingPrograms.get(i).getTrainingContent());
                            program9.add(temp);
                        }
                    }
                    else  if (childTrainingPrograms.get(i).getTrainingModule() == 30){
                        temp.put("name",childTrainingPrograms.get(i).getTrainingName());
                        temp.put("content", childTrainingPrograms.get(i).getTrainingContent());
                        program30.add(temp);
                    }
                    else  if (childTrainingPrograms.get(i).getTrainingModule() == 40){
                        if(childTrainingPrograms.get(i).getTrainingPlan() == 40){
                            temp.put("name",childTrainingPrograms.get(i).getTrainingName());
                            temp.put("content", childTrainingPrograms.get(i).getTrainingContent());
                            program40.add(temp);
                        }
                        if(childTrainingPrograms.get(i).getTrainingPlan() == 41){
                            temp.put("name",childTrainingPrograms.get(i).getTrainingName());
                            temp.put("content", childTrainingPrograms.get(i).getTrainingContent());
                            program41.add(temp);
                        }
                        if(childTrainingPrograms.get(i).getTrainingPlan() == 42){
                            temp.put("name",childTrainingPrograms.get(i).getTrainingName());
                            temp.put("content", childTrainingPrograms.get(i).getTrainingContent());
                            program42.add(temp);
                        }
                    }
                    else  if (childTrainingPrograms.get(i).getTrainingModule() == 50){
                        temp.put("name",childTrainingPrograms.get(i).getTrainingName());
                        temp.put("content", childTrainingPrograms.get(i).getTrainingContent());
                        program50.add(temp);
                    }
                }
            }
            map.put("program1", program1);
            map.put("program2", program2);
            map.put("program3", program3);
            map.put("program4", program4);
            map.put("program5", program5);
            map.put("program6", program6);
            map.put("program7", program7);
            map.put("program8", program8);
            map.put("program9", program9);
            map.put("program30", program30);
            map.put("program40", program40);
            map.put("program41", program41);
            map.put("program42", program42);
            map.put("program50", program50);

        }
        else if(urlType == 2){
            List<String> trainingNameList = new ArrayList<>();
              for (int i = 0; i < childTrainingPrograms.size(); i++) {
                ChildTrainingProgram childTrainingProgram = childTrainingPrograms.get(i);
//                if(trainingName ==null ||trainingName ==""){
                  String trainingName = childTrainingProgram.getTrainingContent();
                      if (!StringUtils.isEmpty(childTrainingProgram.getTrainingContent()) && childTrainingProgram.getTrainingContent().length() > 30) {
                          trainingName = childTrainingProgram.getTrainingContent().substring(0, 30)+"...";
                      }
//                }
//                if(!StringUtils.isEmpty(childTrainingProgram.getTrainingContent()) && childTrainingProgram.getTrainingContent().length()>15){
//                    trainingContent = childTrainingProgram.getTrainingContent().substring(0,15);
//                }
                if (childTrainingProgram.getTrainingType() != null && childTrainingProgram.getTrainingType() == 2) {
                    map.put("trainingContent" + (i + 1), "*" + trainingName);
                    trainingNameList.add( "*" + trainingName);
                } else {
                    map.put("trainingContent" + (i + 1), trainingName);
                    trainingNameList.add(trainingName);
                }
            }
            if (childTrainingPrograms.size() < 14) {
                for (int j = childTrainingPrograms.size(); j < 14; j++) {
                    map.put("trainingContent" + (j + 1), "");
                }
            }
            if(trainingNameList.size()<15){
                int iSize = 15-trainingNameList.size();
                for(int i=0;i<iSize;i++){
                    trainingNameList.add("");
                }
            }
            map.put("trainingNameList",trainingNameList);
        }
        String dest = null;
        String templateName = null;
        if(urlType == 1){
            if(listConsolidatesDTO.getProjectType() != null) {

                if(listConsolidatesDTO.getProjectType() == 1) {
                    templateName = "trainingPlan1.html";
                }
                 if(listConsolidatesDTO.getProjectType() == 2) {
                    templateName = "trainingPlan2.html";
                }
                 if(listConsolidatesDTO.getProjectType() == 3) {
                    templateName = "trainingPlan3.html";
                }
                if(listConsolidatesDTO.getIsNewProgram()!=null && listConsolidatesDTO.getIsNewProgram() == 1) {
                    templateName = "trainingPlan4.html";//新生标准计划
                }
            }
        }
        else if(urlType == 2){
            templateName = "trainingScore.html";
        }
        try {
            String fileName ="";
            if(urlType == 1) {
                 fileName = "训练计划-"+map.get("childName")+"-"+checkProgramDTO.getProjectName()+"-"+checkProgramDTO.getScheduleTime();
            }
            else if(urlType == 2){
                fileName = "项目成绩记录表-"+map.get("childName")+"-"+checkProgramDTO.getProjectName()+"-"+checkProgramDTO.getScheduleTime();
            }
            dest = HtmlToPdf1Utils.toPdf(map, templateName, fileName);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dest;
    }

    public String createReportRender(TrainingReportDTO trainingReportDTO) {
        // 创建渲染PDF内容
        Map<String, Object> map = new HashMap<>();
        // 基础信息
        map.put("childName", trainingReportDTO.getChildName());
        map.put("childAge", trainingReportDTO.getChildAge());
        map.put("monthTime", trainingReportDTO.getMonthTime());
        map.put("scheduleTime", trainingReportDTO.getScheduleTime());
        map.put("teacherName1", trainingReportDTO.getTeacherName1());
        map.put("teacherName2", trainingReportDTO.getTeacherName2());
        map.put("teacherName3", trainingReportDTO.getTeacherName3());
        map.put("program1", trainingReportDTO.getProgram1());
        map.put("program2", trainingReportDTO.getProgram2());
        map.put("program3", trainingReportDTO.getProgram3());
        map.put("program4", trainingReportDTO.getProgram4());
        map.put("program5", trainingReportDTO.getProgram5());
        map.put("program6", trainingReportDTO.getProgram6());
        map.put("program7", trainingReportDTO.getProgram7());
        map.put("program8", trainingReportDTO.getProgram8());
        map.put("program9", trainingReportDTO.getProgram9());
        map.put("rateStr1", trainingReportDTO.getRateStr1());
        map.put("rateStr2", trainingReportDTO.getRateStr2());
        map.put("rateStr3", trainingReportDTO.getRateStr3());
        map.put("rateStr4", trainingReportDTO.getRateStr4());
        map.put("rateStr5", trainingReportDTO.getRateStr5());
        map.put("rateStr6", trainingReportDTO.getRateStr6());
        map.put("rateStr7", trainingReportDTO.getRateStr7());
        map.put("rateStr8", trainingReportDTO.getRateStr8());
        String dest = null;
        String templateName = "trainnigReport.html";
        try {
            String fileName = "家长报告-"+map.get("childName")+"-"+ trainingReportDTO.getScheduleTime();
            dest = HtmlToPdf1Utils.toPdf(map, templateName, fileName);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dest;
    }

    @Override
    public String getConfirmDate(Long childId,Integer projectType, String trainingProgramNumber) {
        return this.childTrainingProgramMapper.getConfirmDate(childId,projectType,trainingProgramNumber);
    }

    @Override
    public EvaluateInfoDTO getEvaluateInfo(Long childId, Integer projectType, String trainingProgramNumber) {
        return this.childTrainingProgramMapper.getEvaluateInfo(childId,projectType,trainingProgramNumber);
    }

    @Override
    public int countNewProgram(Long childId,  String trainingProgramNumber,Integer projectType) {
        return this.childTrainingProgramMapper.countNewProgram(childId,trainingProgramNumber,projectType);
    }
}
